import AddTokenDto from "../utils/dto/token/addTokenDto";
import {$host} from "./index";
import GetUserTokensDto from "../utils/dto/token/getUserTokensDto";
import GetTokensDto from "../utils/dto/token/getTokensDto";

export const addToken = async (dto: AddTokenDto) => {
    return await $host.post('api/Token/PostAddToken', dto)
}

export const getUserTokens = async (dto: GetUserTokensDto) => {
    const params = new URLSearchParams();

    if (dto.filter)
        params.append('filter', dto.filter);
    params.append('pageNumber', dto.pageNumber.toString());
    params.append('pageSize', dto.pageSize.toString());
    params.append('userInfoId', dto.userInfoId);

    return await $host.get(`api/Token/GetUserTokens?${params.toString()}`);
}

export const getTokens = async (dto: GetTokensDto) => {
    const params = new URLSearchParams();

    if (dto.filter)
        params.append('filter', dto.filter);
    params.append('pageNumber', dto.pageNumber.toString());
    params.append('pageSize', dto.pageSize.toString());

    return await $host.get(`api/Token/GetTokens?${params.toString()}`);
}

export const getTokenById = async (tokenId: string) => {
    return await $host.get(`api/Token/GetTokenById/${tokenId}`)
}